﻿Imports BUS
Public Class FormDanhSachPhieuNhap

    Dim flag As Integer = 0
    Private Sub FormQuanLyPhieuNhap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadPhieuNhap()
        dgvPhieuNhap.ClearSelection()
        flag = 1
    End Sub

#Region "Load phiếu nhập"
    Public Sub LoadPhieuNhap()
        Dim tb As DataTable = PhieuNhap_BUS.LoadPhieuNhap()
        dgvPhieuNhap.DataSource = tb
        dgvPhieuNhap.Columns(0).Visible = False
        dgvPhieuNhap.Columns(1).HeaderText = "Ngày nhập"
    End Sub
#End Region

#Region "Xử lý thay đổi dòng chọn trong datagridview"
    Private Sub dgvPhieuNhap_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgvPhieuNhap.SelectionChanged
        If flag = 1 Then
            Dim ma As Integer = Integer.Parse(dgvPhieuNhap.CurrentRow.Cells(0).Value)
            Dim tb As DataTable = PhieuNhap_BUS.LoadPhieuNhapTheoMa(ma)
            dgvChiTiet.DataSource = tb
            dgvChiTiet.Columns(0).HeaderText = "Tên Sách"
            dgvChiTiet.Columns(1).HeaderText = "Số Lượng Nhập"
        End If
    End Sub
#End Region

    Private Sub ButtonThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonThoat.Click
        Me.Close()
    End Sub
End Class